;var url = window.location.pathname;
mui.init({
    swipeBack: false,
    pullRefresh: {
        container: '#mui-content',
        up: {
            contentrefresh: '正在加载...',
            callback: pullupRefresh
        }
    }
});
var index = 1;
var title = $("input[name='title']").val();
function pullupRefresh() {
    var info=$(".custom-lecture").attr("content");
    setTimeout(function () {
        var count = 1;
        if(info=="application"){
            count=Math.ceil(($("input[name='current']").val()) / 20);
        }else {
            count=Math.ceil(($("input[name='current']").val()) / 11);
        }
        ++index;
        if (index<=count) {
            mui('#mui-content').pullRefresh().endPullupToRefresh(false);
            if("notice"==info){
                ajaxListNotice(index);
            }else if ("dispatch"==info){
                ajaxListDispatch(index);
            }else if ("lecture"==info){
                ajaxListLecture(index);
            }else if("application"==info){
                ajaxApplication(index);
            }
        }else {
            mui('#mui-content').pullRefresh().endPullupToRefresh(true);
        }
    }, 1000);
}
$(".custom-search-span").on("tap", function () {
    $(".mui-search").attr("action", url).submit();
});
$(".mui-table-view-cell a").on("tap",function () {
    var href=$(this).attr("href");
    window.location.href=href;
});
function ajaxListNotice(pager) {
    $.ajax({
        type:"GET",
        url:"/uc/schedule/message/list",
        data: {"content": pager, "title": title},
        dataType:"json",
        error:function () {
            console.log("请求失败！");
        },
        success:function (data) {
            var html="";
            if(null!=data&&""!=data){
                var dataList=data.dataList;
                if(null!=dataList&&dataList.length>0){
                    for (var i=0;i<dataList.length;i++){
                        html=html+"<li class='mui-table-view-cell mui-media'>" +
                            "<a class='mui-navigate-right' href='/uc/schedule/message/"+dataList[i].messageId+"/index'>" +
                            "<div class='mui-media-body mui-ellipsis'>"+dataList[i].messageTitle+
                            "<p class='mui-ellipsis custom-ellipsis-size'>时间："+dataList[i].sendTime+"</p>" +
                            "</div></a></li>";
                    }
                }
            }
            $(".custom-lecture").append(html);
        }
    });
}
function ajaxListDispatch(pager) {
    $.ajax({
        type:"GET",
        url:"/uc/schedule/ajax/user/dispatch",
        data: {"content": pager, "title": title},
        dataType:"json",
        error:function () {
            console.log("请求失败！");
        },success:function (data) {
            var html="";
            if(null!=data&&""!=data) {
                var dataList = data.dataList;
                if (null != dataList && dataList.length > 0) {
                    for (var i=0;i<dataList.length;i++){
                        html=html+"<li class='mui-table-view-cell mui-media'>" +
                            "<a class='mui-navigate-right'  content='"+dataList[i].id+"'>" +
                            "<div class='mui-media-body mui-ellipsis'>"+dataList[i].bt+
                            "<p class='mui-ellipsis custom-ellipsis-size'>文号："+dataList[i].wh+"</p>" +
                            "</div></a></li>";
                    }
                }
            }
            $(".custom-lecture").append(html);
        }
    });
}
function ajaxListLecture(pager) {
    $.ajax({
        type:"GET",
        url:"/uc/schedule/ajax/user/lecture",
        data: {"content": pager, "title": title},
        dataType:"json",
        error:function () {
            console.log("请求失败！");
        },success:function (data) {
            var html="";
            if(null!=data&&""!=data) {
                var dataList = data.dataList;
                if (null != dataList && dataList.length > 0) {
                    for (var i=0;i<dataList.length;i++){
                        html=html+"<li class='mui-table-view-cell mui-media'>" +
                            "<a class='mui-navigate-right' href='/uc/schedule/entity/"+dataList[i].id+"/lecture'>" +
                            "<div class='mui-media-body mui-ellipsis'>"+dataList[i].bt+
                            "<p class='mui-ellipsis custom-ellipsis-size'>时间："+dataList[i].sj+"</p>" +
                            "</div></a></li>";
                    }
                }
            }
            $(".custom-lecture").append(html);
        }
    });
}
function ajaxApplication(pager) {
    $.ajax({
        type:"GET",
        url:"/uc/schedule/application/ajax",
        data: {"content": pager, "title": title},
        dataType:"json",
        error:function () {
            console.log("请求失败！");
        },
        success:function (data) {
            var html="";
            if(null!=data&&""!=data){
                var dataList=data.dataList;
                if(null!=dataList&&dataList.length>0){
                    for (var i=0;i<dataList.length;i++){
                        html=html+"<li class='mui-table-view-cell mui-media mui-col-xs-4'>" +
                            "<a href='"+dataList[i].path+"'>" +
                            "<img class='mui-media-object' src='"+dataList[i].image+"'>" +
                            "<div class='mui-media-body'>"+dataList[i].name+"</div>" +
                            "</a></li>";
                    }
                }
            }
            $(".custom-lecture").append(html);
        }
    });
}